//
//  UIViewController+ext.swift
//  SlidebarMenu
//
//  Created by hopy on 2017/10/29.
//  Copyright © 2017年 AppCoda. All rights reserved.
//

import UIKit

extension UIViewController{
    func addSideBarMenu(leftMenuButton:UIBarButtonItem?,rightMenuButton:UIBarButtonItem?=nil){
        if let revealVC = revealViewController(){
            if let menuButton = leftMenuButton{
                menuButton.target = revealVC
                menuButton.action = #selector(SWRevealViewController.revealToggle(_:))
            }
            
            if let extraButton = rightMenuButton{
                revealVC.rightViewRevealWidth = 150
                extraButton.target = revealVC
                extraButton.action = #selector(SWRevealViewController.rightRevealToggle(_:))
            }
            
            view.addGestureRecognizer(revealVC.panGestureRecognizer())
        }
        
    }
}
